//
//  CZStatusBottomView.swift
//  sinaWeiboswift
//
//  Created by 段文杰 on 16/4/14.
//  Copyright © 2016年 段文杰. All rights reserved.
//

import UIKit

class CZStatusBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        //添加子控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(likeButton)

        
        //设置约束
        
        retweetButton.snp_makeConstraints { (make) in
            make.top.leading.bottom.equalTo(self)
        }
        
        commentButton.snp_makeConstraints { (make) in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetButton)
        }
        likeButton.snp_makeConstraints { (make) in
            make.top.trailing.bottom.equalTo(self)
            make.leading.equalTo(commentButton.snp_trailing)
            make.width.equalTo(commentButton)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    // MARK: - 懒加载
    /// 转发按钮
    private lazy var retweetButton: UIButton = {
        let button = UIButton()
        
        // 设置按钮背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("转发", forState: UIControlState.Normal)
        button.addTarget(self, action: #selector(CZStatusBottomView.retBntDidClick), forControlEvents: .TouchUpInside)
        return button
    }()
    
    /// 评论按钮
    private lazy var commentButton: UIButton = {
        let button = UIButton()
        
        // 设置按钮背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("评论", forState: UIControlState.Normal)
        button.addTarget(self, action: #selector(CZStatusBottomView.commentBntDidClick), forControlEvents: .TouchUpInside)
       
        return button
    }()
    
    /// 赞
    private lazy var likeButton: UIButton = {
        let button = UIButton()
        
        // 设置按钮背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        
        // 设置按钮图片
        button.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
        
        // 设置按钮标题
        button.setTitle("赞", forState: UIControlState.Normal)
        button.addTarget(self, action: #selector(CZStatusBottomView.likeBntDidClick), forControlEvents: .TouchUpInside)
        return button
    }()

    
    @objc  func retBntDidClick(){
    HMPrint("转发按钮点击了")
    
    }
    @objc  func commentBntDidClick(){
        
        HMPrint("评论按钮点击了")

    }
    @objc  func likeBntDidClick(){
        HMPrint("赞按钮点击了")

        
    }
}
